package com.yhs.YShop.moudle.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yhs.YShop.moudle.user.dto.UserDto;
import com.yhs.YShop.moudle.user.mapper.UserLogRepository;
import com.yhs.YShop.moudle.user.mapper.UserRepository;
import com.yhs.YShop.moudle.user.model.User;
import com.yhs.YShop.moudle.user.model.UserLog;
import com.yhs.YShop.moudle.user.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {

	@Autowired
	private UserLogRepository userLogRepository;
	@Autowired
	private UserRepository userRepository;

	@Override
	public Page<UserLog> findAllUserLog(Pageable pageable) {
		return userLogRepository.findAll(pageable);
	}

	@Override
	public Page<User> selectPageUserInfo(Pageable pageable) {
		return userRepository.findAll(pageable);
	}

	@Override
	public Integer addUser(UserDto userDto) throws Exception {
		User user = userRepository.save((User)userDto.clone());
		return user.getId();
	}
	
}
